From 4ad5eba90377f0d98351089bf088a9b5a266e2cb Mon Sep 17 00:00:00 2001 From: Daniel Sabo Date: Mon, 29 Apr 2013 20:13:10 -0700 Subject: [PATCH] gggl.c: Remove dead code --- extensions/gggl.c | 560 +++++----------------------------------------- 1 file changed, 61 insertions(+), 499 deletions(-) diff --git a/extensions/gggl.c b/extensions/gggl.c index 5b57c69..29b4c51 100644 --- a/extensions/gggl.c +++ b/extensions/gggl.c @@ -30,9 +30,6 @@ #include "babl.h" #include "extensions/util.h" - -#define INLINE inline - /* * Implemented according to information read from: * @@ -149,7 +146,7 @@ gggl_float_to_index16 (float f) return u.s[1]; } -static INLINE long +static long conv_F_8 (unsigned char *src, unsigned char *dst, long samples) { long n = samples; @@ -166,7 +163,7 @@ conv_F_8 (unsigned char *src, unsigned char *dst, long samples) return samples; } -static INLINE long +static long conv_F_16 (unsigned char *src, unsigned char *dst, long samples) { long n = samples; @@ -183,7 +180,7 @@ conv_F_16 (unsigned char *src, unsigned char *dst, long samples) return samples; } -static INLINE long +static long conv_8_F (unsigned char *src, unsigned char *dst, long samples) { long n = samples; @@ -199,7 +196,7 @@ conv_8_F (unsigned char *src, unsigned char *dst, long samples) return samples; } -static INLINE long +static long conv_16_F (unsigned char *src, unsigned char *dst, long samples) { long n = samples; @@ -215,7 +212,7 @@ conv_16_F (unsigned char *src, unsigned char *dst, long samples) return samples; } -static INLINE long +static long conv_rgbaF_rgb8 (unsigned char *src, unsigned char *dst, long samples) { long n = samples; @@ -244,7 +241,7 @@ conv_rgbaF_rgb8 (unsigned char *src, unsigned char *dst, long samples) #else -static INLINE long +static long conv_F_8 (unsigned char *src, unsigned char *dst, long samples) { long n = samples; @@ -264,7 +261,7 @@ conv_F_8 (unsigned char *src, unsigned char *dst, long samples) return samples; } -static INLINE long +static long conv_F_16 (unsigned char *src, unsigned char *dst, long samples) { long n = samples; @@ -290,7 +287,7 @@ conv_F_16 (unsigned char *src, unsigned char *dst, long samples) return samples; } -static INLINE long +static long conv_8_F (unsigned char *src, unsigned char *dst, long samples) { long n = samples; @@ -304,7 +301,7 @@ conv_8_F (unsigned char *src, unsigned char *dst, long samples) return samples; } -static INLINE long +static long conv_16_F (unsigned char *src, unsigned char *dst, long samples) { long n = samples; @@ -318,7 +315,7 @@ conv_16_F (unsigned char *src, unsigned char *dst, long samples) return samples; } -static INLINE long +static long conv_rgbaF_rgb8 (unsigned char *src, unsigned char *dst, long samples) { long n = samples; @@ -347,7 +344,7 @@ conv_rgbaF_rgb8 (unsigned char *src, unsigned char *dst, long samples) #endif -static INLINE long +static long conv_F_D (unsigned char *src, unsigned char *dst, long samples) { long n = samples; @@ -361,7 +358,7 @@ conv_F_D (unsigned char *src, unsigned char *dst, long samples) return samples; } -static INLINE long +static long conv_D_F (unsigned char *src, unsigned char *dst, long samples) { long n = samples; @@ -375,7 +372,7 @@ conv_D_F (unsigned char *src, unsigned char *dst, long samples) return samples; } -static INLINE long +static long conv_16_8 (unsigned char *src, unsigned char *dst, long samples) { long n = samples; @@ -390,7 +387,7 @@ conv_16_8 (unsigned char *src, unsigned char *dst, long samples) return samples; } -static INLINE long +static long conv_8_16 (unsigned char *src, unsigned char *dst, long samples) { long n = samples; @@ -406,23 +403,21 @@ conv_8_16 (unsigned char *src, unsigned char *dst, long samples) /*********/ -static INLINE long +static long conv_rgbaF_rgba8 (unsigned char *src, unsigned char *dst, long samples) { conv_F_8 (src, dst, samples * 4); return samples; } -#define conv_rgbaF_rgbP8 conv_rgbaF_rgba8 - -static INLINE long +static long conv_rgbF_rgb8 (unsigned char *src, unsigned char *dst, long samples) { conv_F_8 (src, dst, samples * 3); return samples; } -static INLINE long +static long conv_gaF_ga8 (unsigned char *src, unsigned char *dst, long samples) { conv_F_8 (src, dst, samples * 2); @@ -433,21 +428,21 @@ conv_gaF_ga8 (unsigned char *src, unsigned char *dst, long samples) #define conv_gF_g8 conv_F_8 #define conv_gAF_gA8 conv_gaF_ga8 -static INLINE long +static long conv_rgbaF_rgba16 (unsigned char *src, unsigned char *dst, long samples) { conv_F_16 (src, dst, samples * 4); return samples; } -static INLINE long +static long conv_rgbF_rgb16 (unsigned char *src, unsigned char *dst, long samples) { conv_F_16 (src, dst, samples * 3); return samples; } -static INLINE long +static long conv_gaF_ga16 (unsigned char *src, unsigned char *dst, long samples) { conv_F_16 (src, dst, samples * 2); @@ -458,19 +453,19 @@ conv_gaF_ga16 (unsigned char *src, unsigned char *dst, long samples) #define conv_gF_g16 conv_F_16 #define conv_gAF_gA16 conv_gaF_ga16 -static INLINE long +static long conv_rgba8_rgbaF (unsigned char *src, unsigned char *dst, long samples) { return conv_8_F (src, dst, samples * 4) / 4; } -static INLINE long +static long conv_rgb8_rgbF (unsigned char *src, unsigned char *dst, long samples) { return conv_8_F (src, dst, samples * 3) / 3; } -static INLINE long +static long conv_ga8_gaF (unsigned char *src, unsigned char *dst, long samples) { return conv_8_F (src, dst, samples * 2) / 2; @@ -480,35 +475,35 @@ conv_ga8_gaF (unsigned char *src, unsigned char *dst, long samples) #define conv_gA8_gAF conv_ga8_gaF #define conv_g8_gF conv_8_F -static INLINE long +static long conv_rgbaF_rgbaD (unsigned char *src, unsigned char *dst, long samples) { conv_F_D (src, dst, samples * 4); return samples; } -static INLINE long +static long conv_rgbaD_rgbaF (unsigned char *src, unsigned char *dst, long samples) { conv_D_F (src, dst, samples * 4); return samples; } -static INLINE long +static long conv_rgba16_rgbaF (unsigned char *src, unsigned char *dst, long samples) { conv_16_F (src, dst, samples * 4); return samples; } -static INLINE long +static long conv_rgb16_rgbF (unsigned char *src, unsigned char *dst, long samples) { conv_16_F (src, dst, samples * 3); return samples; } -static INLINE long +static long conv_ga16_gaF (unsigned char *src, unsigned char *dst, long samples) { conv_16_F (src, dst, samples * 2); @@ -519,21 +514,21 @@ conv_ga16_gaF (unsigned char *src, unsigned char *dst, long samples) #define conv_gA16_gAF conv_ga16_gaF #define conv_g16_gF conv_16_F -static INLINE long +static long conv_rgba16_rgba8 (unsigned char *src, unsigned char *dst, long samples) { conv_16_8 (src, dst, samples * 4); return samples; } -static INLINE long +static long conv_rgb16_rgb8 (unsigned char *src, unsigned char *dst, long samples) { conv_16_8 (src, dst, samples * 3); return samples; } -static INLINE long +static long conv_ga16_ga8 (unsigned char *src, unsigned char *dst, long samples) { conv_16_8 (src, dst, samples * 2); @@ -544,21 +539,21 @@ conv_ga16_ga8 (unsigned char *src, unsigned char *dst, long samples) #define conv_gA16_gA8 conv_ga16_ga8 #define conv_g16_g8 conv_16_8 -static INLINE long +static long conv_rgba8_rgba16 (unsigned char *src, unsigned char *dst, long samples) { conv_8_16 (src, dst, samples * 4); return samples; } -static INLINE long +static long conv_rgb8_rgb16 (unsigned char *src, unsigned char *dst, long samples) { conv_8_16 (src, dst, samples * 3); return samples; } -static INLINE long +static long conv_ga8_ga16 (unsigned char *src, unsigned char *dst, long samples) { conv_8_16 (src, dst, samples * 2); @@ -571,7 +566,7 @@ conv_ga8_ga16 (unsigned char *src, unsigned char *dst, long samples) /* alpha conversions */ -static INLINE long +static long conv_gaF_gAF (unsigned char *src, unsigned char *dst, long samples) { long n = samples; @@ -590,7 +585,7 @@ conv_gaF_gAF (unsigned char *src, unsigned char *dst, long samples) return samples; } -static INLINE long +static long conv_gAF_gaF (unsigned char *src, unsigned char *dst, long samples) { long n = samples; @@ -611,7 +606,7 @@ conv_gAF_gaF (unsigned char *src, unsigned char *dst, long samples) /* alpha stripping and adding */ -static INLINE long +static long conv_rgbaF_rgbF (unsigned char *src, unsigned char *dst, long samples) { long n = samples; @@ -632,7 +627,7 @@ conv_rgbaF_rgbF (unsigned char *src, unsigned char *dst, long samples) return samples; } -static INLINE long +static long conv_rgbF_rgbaF (unsigned char *src, unsigned char *dst, long samples) { long n = samples; @@ -654,7 +649,7 @@ conv_rgbF_rgbaF (unsigned char *src, unsigned char *dst, long samples) return samples; } -static INLINE long +static long conv_gaF_gF (unsigned char *src, unsigned char *dst, long samples) { long n = samples; @@ -669,7 +664,7 @@ conv_gaF_gF (unsigned char *src, unsigned char *dst, long samples) return samples; } -static INLINE long +static long conv_gF_gaF (unsigned char *src, unsigned char *dst, long samples) { long n = samples; @@ -691,7 +686,7 @@ conv_gF_gaF (unsigned char *src, unsigned char *dst, long samples) /* colorchannel dropping and adding */ -static INLINE long +static long conv_gF_rgbF (unsigned char *src, unsigned char *dst, long samples) { long n = samples; @@ -710,7 +705,7 @@ conv_gF_rgbF (unsigned char *src, unsigned char *dst, long samples) return samples; } -static INLINE long +static long conv_gaF_rgbaF (unsigned char *src, unsigned char *dst, long samples) { long n = samples; @@ -737,7 +732,7 @@ conv_gaF_rgbaF (unsigned char *src, unsigned char *dst, long samples) /* other conversions coded for some optimisation reason or sumthin */ -static INLINE long +static long conv_rgbaF_rgbA8 (unsigned char *src, unsigned char *dst, long samples) { long n = samples; @@ -760,30 +755,7 @@ conv_rgbaF_rgbA8 (unsigned char *src, unsigned char *dst, long samples) return samples; } -static INLINE long -conv_rgbaF_rgbA16 (unsigned char *src, unsigned char *dst, long samples) -{ - long n = samples; - - while (n--) - { - float alpha = (*(float *) src + (4 * 3)); - int c; - - for (c = 0; c < 3; c++) - { - *(unsigned short *) dst = lrint (((*(float *) src) * alpha) * 65535.0); - dst += 2; - src += 4; - } - *(unsigned short *) dst = lrint (alpha * 65535.0); - dst += 2; - src += 4; - } - return samples; -} - -static INLINE long +static long conv_rgbaF_rgb16 (unsigned char *src, unsigned char *dst, long samples) { long n = samples; @@ -803,29 +775,7 @@ conv_rgbaF_rgb16 (unsigned char *src, unsigned char *dst, long samples) return samples; } -static INLINE long -conv_rgbP8_rgbaF (unsigned char *src, unsigned char *dst, long samples) -{ - long n = samples; - - while (n--) - { - int c; - - for (c = 0; c < 3; c++) - { - (*(float *) dst) = *(unsigned char *) src / 255.0; - dst += 4; - src += 1; - } - (*(float *) dst) = 1.0; - dst += 4; - src += 1; - } - return samples; -} - -static INLINE long +static long conv_rgbA16_rgbaF (unsigned char *src, unsigned char *dst, long samples) { long n = samples; @@ -849,7 +799,7 @@ conv_rgbA16_rgbaF (unsigned char *src, unsigned char *dst, long samples) } /* - static INLINE long + static long conv_rgb8_rgbaF (unsigned char *src, unsigned char *dst, int samples) @@ -869,7 +819,7 @@ conv_rgbA16_rgbaF (unsigned char *src, unsigned char *dst, long samples) return samples; } - static INLINE long + static long conv_g8_rgbaF (unsigned char *src, unsigned char *dst, int samples) @@ -889,7 +839,7 @@ conv_rgbA16_rgbaF (unsigned char *src, unsigned char *dst, long samples) return samples; } - static INLINE long + static long conv_rgb16_rgbaF (unsigned char *src, unsigned char *dst, int samples) @@ -910,7 +860,7 @@ conv_rgbA16_rgbaF (unsigned char *src, unsigned char *dst, long samples) return samples; } - static INLINE long + static long conv_gF_rgbaF (unsigned char *src, unsigned char *dst, int samples) @@ -931,7 +881,7 @@ conv_rgbA16_rgbaF (unsigned char *src, unsigned char *dst, long samples) return samples; } */ -static INLINE long +static long conv_rgba8_rgbA8 (unsigned char *src, unsigned char *dst, long samples) { long n = samples; @@ -960,7 +910,7 @@ conv_rgba8_rgbA8 (unsigned char *src, unsigned char *dst, long samples) return samples; } -static INLINE long +static long conv_rgbA8_rgba8 (unsigned char *src, unsigned char *dst, long samples) { long n = samples; @@ -990,161 +940,7 @@ conv_rgbA8_rgba8 (unsigned char *src, unsigned char *dst, long samples) return samples; } -static INLINE long -conv_argb8_rgba8 (unsigned char *src, unsigned char *dst, long samples) -{ - long n = samples; - - while (n--) - { - dst[0] = src[2]; - dst[1] = src[1]; - dst[2] = src[0]; - dst[3] = src[3]; - src += 4; - dst += 4; - } - return samples; -} - -static INLINE long -conv_rgba8_argb8 (unsigned char *src, unsigned char *dst, long samples) -{ - long n = samples; - - while (n--) - { - dst[0] = src[3]; - dst[1] = src[0]; - dst[2] = src[1]; - dst[3] = src[2]; - src += 4; - dst += 4; - } - return samples; -} - -static INLINE long -conv_Argb8_rgbA8 (unsigned char *src, unsigned char *dst, long samples) -{ - long n = samples; - - while (n--) - { - dst[0] = src[2]; - dst[1] = src[1]; - dst[2] = src[0]; - dst[3] = src[3]; - src += 4; - dst += 4; - } - return samples; -} - -static INLINE long -conv_rgbA8_Argb8 (unsigned char *src, unsigned char *dst, long samples) -{ - long n = samples; - - while (n--) - { - dst[0] = src[2]; - dst[1] = src[1]; - dst[2] = src[0]; - dst[3] = src[3]; - src += 4; - dst += 4; - } - return samples; -} - -static INLINE long -conv_Prgb8_rgbP8 (unsigned char *src, unsigned char *dst, long samples) -{ - long n = samples; - - while (n--) - { - dst[0] = src[2]; - dst[1] = src[1]; - dst[2] = src[0]; - dst[3] = 255; - src += 4; - dst += 4; - } - return samples; -} - -static INLINE long -conv_rgbP8_Prgb8 (unsigned char *src, unsigned char *dst, long samples) -{ - long n = samples; - - while (n--) - { - dst[0] = src[2]; - dst[1] = src[1]; - dst[2] = src[0]; - dst[3] = 255; - src += 4; - dst += 4; - } - return samples; -} - -static INLINE long -conv_Prgb8_rgb8 (unsigned char *src, unsigned char *dst, long samples) -{ - long n = samples; - - while (n--) - { - dst[0] = src[2]; - dst[1] = src[1]; - dst[2] = src[0]; - /*dst[3] = src[3]; */ - src += 4; - dst += 3; - } - return samples; -} - - -/* FIXME: this is actually BGRP */ -static INLINE long -conv_rgb8_Prgb8 (unsigned char *src, unsigned char *dst, long samples) -{ - long n = samples; - - while (n--) - { - dst[0] = src[2]; /* blue */ - dst[1] = src[1]; /* green */ - dst[2] = src[0]; /* red */ - dst[3] = 255; - src += 3; - dst += 4; - } - return samples; -} - -static INLINE long -conv_rgb8_rgbP8 (unsigned char *src, unsigned char *dst, long samples) -{ - long n = samples; - - while (n--) - { - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; - src += 3; - dst += 4; - } - return samples; -} - -static INLINE long +static long conv_rgb8_rgba8 (unsigned char *src, unsigned char *dst, long samples) { long n = samples; @@ -1166,49 +962,7 @@ conv_rgb8_rgba8 (unsigned char *src, unsigned char *dst, long samples) #define conv_rgb8_rgbA8 conv_rgb8_rgba8 -static INLINE long -conv_rgbP8_rgba8 (unsigned char *src, unsigned char *dst, long samples) -{ - long n = samples; - - while (n--) - { - *(unsigned int *) dst = *(unsigned int *) src; - dst[3] = 255; - src += 4; - dst += 4; - } - return samples; -} - -#define conv_rgbP8_rgbA8 conv_rgbP8_rgba8 - -static INLINE long -conv_rgba8_rgbP8 (unsigned char *src, unsigned char *dst, long samples) -{ - memcpy (dst, src, samples * 4); - return samples; -} - -#define conv_rgbA8_rgbP8 conv_rgba8_rgbP8 - -static INLINE long -conv_rgbP8_rgb8 (unsigned char *src, unsigned char *dst, long samples) -{ - long n = samples; - - while (n--) - { - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; - src += 4; - dst += 3; - } - return samples; -} - -static INLINE long +static long conv_rgba8_rgb8 (unsigned char *src, unsigned char *dst, long samples) { long n = samples; @@ -1224,7 +978,7 @@ conv_rgba8_rgb8 (unsigned char *src, unsigned char *dst, long samples) return samples; } -static INLINE long +static long conv_rgbA8_rgb8 (unsigned char *src, unsigned char *dst, long samples) { long n = samples; @@ -1280,7 +1034,7 @@ conv_rgbA8_rgb8 (unsigned char *src, unsigned char *dst, long samples) - static INLINE long + static long conv_yuvaF_rgbaF (unsigned char *src, unsigned char *dst, long samples) { float *src_f = (float *) src; @@ -1312,7 +1066,7 @@ conv_yuvaF_rgbaF (unsigned char *src, unsigned char *dst, long samples) } -static INLINE long +static long conv_yuvF_rgbF (unsigned char *src, unsigned char *dst, long samples) { float *src_f = (float *) src; @@ -1342,203 +1096,6 @@ conv_yuvF_rgbF (unsigned char *src, unsigned char *dst, long samples) return samples; } - -/******* lab, xyz and rgb interaction, lifted from cpercep by adam d. moss */ - -/* - static const double Xn = 0.951; - static const double Yn = 1.0; - static const double Zn = 1.089; - */ - -#define LXN 0.312713F -#define LYN 0.329016F - -static const double lxn = LXN; -static const double lyn = LYN; -static double xnn = LXN / LYN; -static double znn = (1.0F - (LXN + LYN)) / LYN; - - -static const double LRAMP = 7.99959199F; - -static INLINE long -conv_rgbF_xyzF (unsigned char *src, unsigned char *dst, long samples) -{ - float *src_f = (float *) src; - float *dst_f = (float *) dst; - long n = samples; - - while (n--) - { - float x, y, z; - float red, green, blue; - - red = src_f[0]; - green = src_f[1]; - blue = src_f[2]; - - x = 0.431 * red + 0.342 * green + 0.179 * blue; - y = 0.222 * red + 0.707 * green + 0.071 * blue; - z = 0.020 * red + 0.130 * green + 0.939 * blue; - - dst_f[0] = x; - dst_f[1] = y; - dst_f[2] = z; - dst_f += 3; - src_f += 3; - } - return samples; -} - -static INLINE long -conv_xyzF_rgbF (unsigned char *src, unsigned char *dst, long samples) -{ - float *src_f = (float *) src; - float *dst_f = (float *) dst; - long n = samples; - - while (n--) - { - dst_f[0] = src_f[0]; - dst_f[1] = src_f[1]; - dst_f[2] = src_f[2]; - dst_f += 3; - src_f += 3; - } - return samples; -} - -static INLINE double -ffunc (const double t) -{ - if (t > 0.008856F) - { - return (cbrt (t)); - } - else - { - return (7.787F * t + 16.0F / 116.0F); - } -} - - -static INLINE double -ffunc_inv (const double t) -{ - if (t > 0.206893F) - { - return (t * t * t); - } - else - { - return ((t - 16.0F / 116.0F) / 7.787F); - } -} - -static INLINE long -conv_labF_xyzF (unsigned char *src, unsigned char *dst, long samples) -{ - float *src_f = (float *) src; - float *dst_f = (float *) dst; - long n = samples; - - while (n--) - { - float P; - float X, Y, Z; - float L, a, b; - - L = src_f[0]; - a = src_f[1]; - b = src_f[2]; - - if (L > LRAMP) - { - P = Y = (L + 16.0F) / 116.0F; - Y = Y * Y * Y; - } - else - { - Y = L / 903.3F; - P = 7.787F * Y + 16.0F / 116.0F; - } - - X = (P + a / 500.0F); - X = xnn *ffunc_inv (X); - Z = (P - b / 200.0F); - Z = znn *ffunc_inv (Z); - - - dst_f[0] = X; - dst_f[1] = Y; - dst_f[2] = Z; - dst_f += 3; - src_f += 3; - } - return samples; -} - -static INLINE long -conv_xyzF_labF (unsigned char *src, unsigned char *dst, long samples) -{ - float *src_f = (float *) src; - float *dst_f = (float *) dst; - long n = samples; - - while (n--) - { - double ffuncY; - float X, Y, Z; - float L, a, b; - X = src_f[0]; - Y = src_f[1]; - Z = src_f[2]; - - if (Y > 0.0F) - { - if (Y > 0.008856F) - { - L = (116.0F * cbrt (Y)) - 16.0F; - } - else - { - L = (Y * 903.3F); - } - } - else - { - L = 0.0; - } - - ffuncY = ffunc (Y); - a = 500.0F * (ffunc (X / xnn) - ffuncY); - b = 200.0F * (ffuncY - ffunc (Z / znn)); - - dst_f[0] = L; - dst_f[1] = a; - dst_f[2] = b; - dst_f += 3; - src_f += 3; - } - return samples; -} - -/******* end of cpercep lift out **/ - - -#define MAX_CONVERSIONS 100 - -typedef struct Conversion -{ - int from_fmt; - int to_fmt; - int cost; /* cost of function,. calculated as ms to convert 1024*1024 samples */ - int loss; /* 0 maps ok, 1 precision loss, 2 alpha loss, 4 channel loss - (should be dwelled further into) */ - void (*function)(unsigned char *src, unsigned char *dst, long samples); -} Conversion; - int init (void); int @@ -1754,5 +1311,10 @@ init (void) o (rgbaF, rgbaD); o (rgbaD, rgbaF); +#ifdef USE_TABLES + if (!table_inited) + table_init (); +#endif + return 0; } -- 2.30.2